package com.guanzhi.validation.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;

/**
 * Spring6
 * <p> Package: com.guanzhi.validation.config </p>
 * <p> File: ValidatorConfiguration.java </p>
 * <p> Description:  (实现validation数据校验 配置类)</p>
 * <p> Date: 2024/9/21 18:19</p>
 *
 * @author LiKai
 * @version 1.0 （代码版本）
 * @email <a href="mailto:Likai55634@aliyun.com">LiKai</a>（邮箱）
 * @date 2024/9/21 18:19
 * @since jdk1.8（jdk版本）
 */
@Configuration
public class ValidatorConfiguration {

    /**
     * 使用注解形式 校验
     *
     * @return LocalValidatorFactoryBean
     */
    @Bean
    public LocalValidatorFactoryBean factoryBean() {
        return new LocalValidatorFactoryBean();
    }

    /**
     * 使用方法形式 校验
     *
     * @return MethodValidationPostProcessor
     */
    @Bean
    public MethodValidationPostProcessor methodValidationPostProcessor() {
        return new MethodValidationPostProcessor();
    }
}
